<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<link rel="stylesheet" media="screen" href="css/docs.css"/>

<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<h1 class="page-title">加班费管理-方案${salaryOvertime == null ? "添加" : "修改"}</h1>


<div class="container_12 clearfix leading">

    <form class="form has-validation" id="post_form" name="post_form">
        <div class="clear"></div>
        <h5>加班费方案：<strong>
            <input name="salaryOvertime.title" id="salaryOvertime_title" value="${salaryOvertime.title}" type="text" style="width:30%"></strong></h5>

        <div class="container_12 clearfix" style="margin-left:0px; margin-right:0px">

            <div class="portlet grid_12" style="padding-bottom:20px">
                <header>
                    <h6>缴费基数</h6>

                </header>

                <section>
                    <table class="display" id="example" style="clear:none">
                        <thead>
                        <tr>
                            <th>每月工作天数</th>
                            <th>平时加班</th>
                            <th>周末加班</th>
                            <th>节假日加班</th>
                            <th>挂钩数据</th>
                            <th>手动输入</th>
                        </tr>
                        </thead>                                                                                                               
                        <tbody>
                        <tr class="gradeA">
                            <td><strong>
                                <input name="salaryOvertime.workDay" id="salaryOvertime_workDay" value="${salaryOvertime.workDay}" type="text" style="width:60px"/>
                                天</strong></td>
                            <td><strong>
                                <input name="salaryOvertime.usuallyOvertime" id="salaryOvertime_usuallyOvertime" value="${salaryOvertime.usuallyOvertime}" type="text" style="width:60px"/>
                            </strong>倍
                            </td>
                            <td><strong>
                                <input name="salaryOvertime.weekendOvertime" id="salaryOvertime_weekendOvertime" value="${salaryOvertime.weekendOvertime}" type="text" style="width:60px"/>
                            </strong>倍
                            </td>
                            <td><strong>
                                <input name="salaryOvertime.holidaysOvertime" id="salaryOvertime_holidaysOvertime" value="${salaryOvertime.holidaysOvertime}" type="text" style="width:60px"/>
                            </strong>倍
                            </td>
                            <td><select id="linkedDataType" name="salaryOvertime.linkedDataType" style="opacity: 0;">
                               <option value="no_linked"
											<s:if test="#request.salaryOvertime.linkedDataType != null && #request.salaryOvertime.linkedDataType.toString().equals('no_linked')">selected="selected"</s:if>>无挂钩数据(手动输入)</option>
										<option value="employee_base_salary"
											<s:if test="#request.salaryOvertime.linkedDataType != null && #request.salaryOvertime.linkedDataType.toString().equals('employee_base_salary')">selected="selected"</s:if>>和员工基本工资挂钩</option>
										<option value="employee_performance"
											<s:if test="#request.salaryOvertime.linkedDataType != null && #request.salaryOvertime.linkedDataType.toString().equals('employee_performance')">selected="selected"</s:if>>和员工绩效奖金挂钩</option>
										<option value="employee_salary_performance"
											<s:if test="#request.salaryOvertime.linkedDataType != null && #request.salaryOvertime.linkedDataType.toString().equals('employee_salary_performance')">selected="selected"</s:if>>和员工基本工资+绩效奖金挂钩</option>
										<option value="salary_framework"
											<s:if test="#request.salaryOvertime.linkedDataType != null && #request.salaryOvertime.linkedDataType.toString().equals('salary_framework')">selected="selected"</s:if>>和薪资框架中的项目总和挂钩</option>

                            </select></td>
                            <td><strong>
                                <input name="salaryOvertime.costBase" id="salaryOvertime_costBase" value="${salaryOvertime.costBase}" type="text" style="width:60px"/> 元
                            </strong></td>
                        </tr>
                        </tbody>
                    </table>
                </section>
            </div>
        </div>
        <input type="hidden" name="salaryOvertime.organization.id" value="${organizationId}"/>
        <s:if test="#request.salaryOvertime.id>0">
             <input type="hidden" name="salaryOvertime.id" value="${salaryOvertime.id}"/>
        </s:if>

    </form>
</div>
<div class="clear"></div>
<div class="container_12 clearfix leading" style=" padding-left:20px">
    <div class="form-action clearfix">
        <p>
            <a class="button" href="javascript:void(0)" onclick="checkForm();"><span
                    style="background:url(${ctx}/images/img/page_edit.png)"
                    class="icon">&nbsp;</span>确定提交</a>
            <a class="button" href="#salary/overtime_tax_main.xhtml"><span
                    style="background:url(${ctx}/images/img/arrow_undo.png)" class="icon">&nbsp;</span>返回</a></p>
    </div>

</div>

<script type="text/javascript">

    function checkForm() {
        if (checkNull($("#salaryOvertime_title").attr("value"))) {
            alert("方案名称不能为空");
            return false;
        }
        if(checkNull($("#salaryOvertime_workDay").val())){
            alert("请填写每月工作天数");
            return false;
        }
        if(isNaN($("#salaryOvertime_workDay").val()) || parseFloat($("#salaryOvertime_workDay").val())<0){
            alert("工作天数填写不正确");
            return false;
        }
        if(checkNull($("#salaryOvertime_usuallyOvertime").val())){
            alert("请填写平时加班倍数");
            return false;
        }
        if(isNaN($("#salaryOvertime_usuallyOvertime").val()) || parseFloat($("#salaryOvertime_usuallyOvertime").val())<0){
            alert("平时加班倍数填写不正确");
            return false;
        }
        if(checkNull($("#salaryOvertime_weekendOvertime").val())){
            alert("请填写周未加班倍数");
            return false;
        }
        if(isNaN($("#salaryOvertime_weekendOvertime").val()) || parseFloat($("#salaryOvertime_weekendOvertime").val())<0){
            alert("周未加班倍数填写不正确");
            return false;
        }
        if(checkNull($("#salaryOvertime_holidaysOvertime").val())){
            alert("请填写节假日加班倍数");
            return false;
        }
        if(isNaN($("#salaryOvertime_holidaysOvertime").val()) || parseFloat($("#salaryOvertime_holidaysOvertime").val())<0){
            alert("节假日加班倍数填写不正确");
            return false;
        }
        if($("#linkedDataType").val()=='no_linked') {
            if(checkNull($("#salaryOvertime_costBase").val())){
                alert("方案金额不能为空");
                return false;
            }
        }


        if (isNaN($("#salaryOvertime_costBase").val()) || parseFloat($("#salaryOvertime_costBase").val())<0) {
            alert("方案金额填写不正确");
            return false;
        }
        var url = "${ctx}/salary/overtime_tax_save.xhtml";
        $.ajax(url, {
            type:"POST",
            data:$("#post_form").serialize(),
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url)
            },
            complete:function(b) {
            }
        });
    }


</script>
